/********************************************************************
Name: Make Refugee Attitude Regression Table (Table A1)
Author: Dan Thompson
Date: September 2021
Description: 

********************************************************************/

clear all
set matsize 11000
set maxvar 15000
gl path = "~/Dropbox/Mariel Effects"


* Estimate relationship between Reagan and Carter supporters in
* support for admitting more Cuban refugees and halting immigration
import delim "$path/Replication/data/surveys/a1155g.dat", clear stringcols(_all)
gen pres = substr(v1, 14, 2)
gen cuban = substr(v1, 37, 1)
gen imm = substr(v1, 38, 1)
gen wt = substr(v1, 1, 1)
destring *, replace
gen halt = imm==2 if imm!=0
replace cuban = . if cuban>2
replace cuban = 2 - cuban
gen reagan = inlist(pres, 2, 7) ///
	if inlist(pres, 1, 2, 7, 8)
reg reagan halt [aw=wt], r
local b3 = _b[halt]
local se3 = _se[halt]
local c3 = _b[_cons]
local sec3 = _se[_cons]
local n3 = e(N)
reg reagan cuban [aw=wt], r
local b1 = _b[cuban]
local se1 = _se[cuban]
local c1 = _b[_cons]
local sec1 = _se[_cons]
local n1 = e(N)

* Estimate relationship between Reagan and Carter supporters in
* support for admitting more Vietnamese refugees
import delim "$path/Replication/data/surveys/1135.dat", clear stringcols(_all)
gen pres = substr(v1, 14, 1)
gen viet = substr(v1, 22, 1)
gen wt = substr(v1, 1, 1)
destring *, replace
replace viet = . if viet>2
replace viet = 2 - viet
gen reagan = pres==2 if inlist(pres, 1, 2)
reg reagan viet [aw=wt], r
local b2 = _b[viet]
local se2 = _se[viet]
local c2 = _b[_cons]
local sec2 = _se[_cons]
local n2 = e(N)

* Build Table A1
quietly {
	cap log close
	log using "$path/Replication/output/refugee_attitudes_table.tex", text replace
	noi di "\begin{table}[H]"
	noi di "\centering"
	noi di "\caption{\textbf{Reagan Supporters Modestly Less Supportive of Permitting "
	noi di "Refugees than Carter Supporters.}\label{tab:ref_add}}"
	noi di "\begin{tabular}{lccc}"
	noi di "\toprule \toprule"
	noi di " & \multicolumn{3}{c}{Reagan Support [0,1]} \\[1mm]"
	noi di "\midrule"
	noi di " Admit Cubans & " %3.2f `b1' " & & \\"
	noi di " & (" %3.2f `se1' ") & & \\[2mm]"
	noi di " Admit Vietnamese & & " %3.2f `b2' " & \\"
	noi di " & & (" %3.2f `se2' ") & \\[2mm]"
	noi di " Halt Immigration & & & " %3.2f `b3' " \\"
	noi di " & & & (" %3.2f `se3' ") \\[2mm]"
	noi di " Constant & " %3.2f `c1' " & " %3.2f `c2' " & " %3.2f `c3' " \\"
	noi di " & (" %3.2f `sec1' ") & (" %3.2f `sec2' ") & (" %3.2f `sec3' ") \\[2mm]"
	noi di "\# of Voters & " %8.0fc `n1' " & " %8.0fc `n2' " & " %8.0fc `n3' " \\"
	noi di "\bottomrule \bottomrule"
	noi di "\multicolumn{4}{p{.45\textwidth}}{\footnotesize Robust standard errors "
	noi di "reported in parentheses below each estimate. Voters weighted using Gallup's "
	noi di "provided survey weights.}"
	noi di "\end{tabular}"
	noi di "\end{table}"
	log off
}
